import md5 from 'blueimp-md5'
import request from '@/plugins/axios'

export function login({ username, password }) {
  return request.post('/api/auth/login', { username, password: md5(password) })
}

export function register({ username, password }) {
  return request.post('/api/auth/register', { username, password: md5(password) })
}

export function getUserinfo() {
  return request.get('/api/auth/userinfo')
}


export function getUserinfoById(userId) {
  const params = {}
  userId && Object.assign(params, { userId })

  return request.get('/api/auth/userinfoById', { params })
}